// pages/account/me/me.js
var app = getApp();
let common = require('../../../utils/common');
Page({
  data:{
    userInfo:{},
    balance:'0.00',
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
      that.reqBalance();
    });
  },
  reqBalance(){
    let that = this;
    common.asynPost(common.API.user.balance,{},(data)=>{
      that.setData({
        balance:data['balance']
      });
    },(err)=>{
      console.log(err);
    });
  },
  myOrderCoach:function(){
    wx.navigateTo({url:'../booking/booking'});
  },
  myOrderEvent:function(){
    wx.navigateTo({url:'../activity/activity'});
  },
  registerCoach:function () {
    wx.navigateTo({url:'../edit/edit?type=2'});
  },
  handleEditInfo:function(){
    wx.navigateTo({url:'../edit/edit?type=0'});
  },
  myStudyingEvent:function(){
    wx.navigateTo({url:'../student/student'});
  },
  myTeachingEvent:function(){
    wx.navigateTo({url:'../teaching/teaching'});
  },
  protocol:function () {
    wx.navigateTo({url: '../agreement/agreement'});
  },
  opinion:function () {
    wx.navigateTo({url: '../suggest/suggest'});
  },
  about:function () {
    wx.navigateTo({url: '../about/about'});
  },
  banks(){
    wx.navigateTo({url: '../bank/bank'});
  },
  balance(){
    wx.navigateTo({
      url: '../balance/balance'
    })
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  }
})